#!/usr/bin/env python3
# coding=utf-8
# 作者：hnpyzzd
# 时间：2020-03-23

#1、给出任意一个列表，请查找出x元素是否在列表里面，如果存在返回1，不存在返回0，使用两种方法实现。
#方法1

list1 = [1,2,4,5,7,8,0]
status = 0
x = 3
for l in list1:
    if l == x:
        status = 1
print(status)

#方法2
list1 = [1,2,4,5,7,8,0]
x = 3
if list1.count(x) > 0:
    print(1)
else:
    print(0)

#2、任一个英文的纯文本文件，统计其中的单词出现的个数。
s = 'In my dual profession as an educator and health care provider,\
    I have worked with numerous children infected with the virus that causes AIDS.\
    The relationships that I have had with these special kids have been gifts in my life.\
    They have taught me so many things, but I have especially learned that great courage \
    can be found in the smallest of packages. Let me tell you about Tyler.'
# s = 'In my dual profession, as an educator. and health care, provider, I have worked. with! numerous'
s = s.replace(' ',',').replace('.',',').replace('!',',').replace(';',',').replace('!',',')
s_list = s.split(',')
s_num = 0 
for s in s_list:
    if s :
        s_num+=1
print('单词数量',s_num)
